/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.FileNotFoundException;
import java.util.ArrayList;

/**
 *
 * @author Bjarni
 */
public class Team {
//String team er hvilket hold man vil have liste af.
//Der er 4 at vælge imellem SeniorMale, SeniorFemale, JuniorMale og JuniorFemale
//obs. returnerer ikke hvis alderen er over 65 = pensionist.
//også fejl hvis birthday er andet end 8 chars.
    public ArrayList<Member> teamList(String fileName, String team) throws FileNotFoundException {
        MemberList memberlist = new MemberList();
        ArrayList<Member> list = new ArrayList<Member>();
        ArrayList<Member> templist = memberlist.dataObjectToMember(memberlist.loadAllObjectsFromFile(fileName));
        Member member;
        for (int i = 0; i < templist.size(); i++) {
            member = templist.get(i);
            if (team.equals("SeniorMale")) {
                if (member.getAgeGroup().equals("Senior") && member.getGender().equals("Male")){
                list.add(member);    
                }
            } else if (team.equals("SeniorFemale")) {
                if (member.getAgeGroup().equals("Senior") && member.getGender().equals("Female")){
                list.add(member);
                }
            } else if (team.equals("JuniorMale")) {
                if (member.getAgeGroup().equals("Junior") && member.getGender().equals("Male")){
                list.add(member);
                }
            } else if (team.equals("JuniorFemale")) {
                if (member.getAgeGroup().equals("Junior") && member.getGender().equals("Female")){
                list.add(member);
                }
            }
        }
        return list;
    }
}
